<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" template="/protected/template/template.xhtml">
	<ui:define name="content">
		<p:panel header="Search">
			<p:messages />
			<b><h:outputText value="Criteria" /></b>
			<p:separator />
			<p:panelGrid>
				<p:row>
					<p:column>
						<p:outputLabel value="View" for="view" />
					</p:column>
					<p:column>
						<p:selectOneMenu id="view" value="#{searchBean.selectedView}" required="true" style="width: 320px;">
							<f:selectItems value="#{searchBean.views}" />
						</p:selectOneMenu>
					</p:column>
					<p:column>
						<p:outputLabel value="Tags" for="tags" />
					</p:column>
					<p:column>
						<p:selectCheckboxMenu id="tags" value="#{searchBean.selectedTags}" label="Select" converter="genericEntityConverter" required="true">
							<f:selectItems value="#{searchBean.tags}" var="tag" itemValue="#{tag}" itemLabel="#{tag.name}" />
						</p:selectCheckboxMenu>
					</p:column>
					<p:column>
						<p:outputLabel value="From" for="from" />
					</p:column>
					<p:column>
						<p:calendar id="from" value="#{searchBean.from}" pattern="MM/dd/yyyy HH:mm" required="true" />
					</p:column>
					<p:column>
						<p:outputLabel value="To" for="to" />
					</p:column>
					<p:column>
						<p:calendar id="to" value="#{searchBean.to}" pattern="MM/dd/yyyy HH:mm" required="true" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:outputLabel value="Message" for="message" />
					</p:column>
					<p:column>
						<p:inputText id="message" value="#{searchBean.message}" style="width: 320px;" />
					</p:column>
					<p:column>
						<p:outputLabel value="Severity" for="severities" />
					</p:column>
					<p:column>
						<p:selectCheckboxMenu id="severities" value="#{searchBean.selectedSeverities}" label="Select" required="true">
							<f:selectItems value="#{searchBean.severities}" />
						</p:selectCheckboxMenu>
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<p:commandButton value="Search" action="#{searchBean.search}" ajax="false" />
					</p:column>
				</p:row>
			</p:panelGrid>
			<br />
			<b><h:outputText value="Result" /></b>
			<p:separator />
			<p:dataTable value="#{searchBean.logs}" var="log" paginator="true" paginatorPosition="bottom" rows="10">
				<p:column sortBy="#{log.timestamp}" style="text-align: center; width: 150px;">
					<f:facet name="header">
						<h:outputText value="Timestamp" />
					</f:facet>
					<h:outputText value="#{log.timestamp}">
						<f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
					</h:outputText>
				</p:column>
				<p:column sortBy="#{log.message}">
					<f:facet name="header">
						<h:outputText value="Message" />
					</f:facet>
					<h:outputText value="#{log.message}" />
				</p:column>
				<p:column style="text-align: center; width: 50px;">
					<p:commandButton icon="ui-icon-zoomin" update=":contentForm:display" oncomplete="dialogWidget.show()">
						<f:setPropertyActionListener target="#{searchBean.selectedLog}" value="#{log}" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</p:panel>
		<p:dialog widgetVar="dialogWidget">
			<p:panelGrid id="display">
				<p:row>
					<p:column>
						<h:outputText value="Timestamp:" />
					</p:column>
					<p:column>
						<h:outputText value="#{searchBean.selectedLog.timestamp}" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<h:outputText value="Message:" />
					</p:column>
					<p:column>
						<h:outputText value="#{searchBean.selectedLog.message}" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<h:outputText value="Severity:" />
					</p:column>
					<p:column>
						<h:outputText value="#{searchBean.selectedLog.severity}" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<h:outputText value="Hostname:" />
					</p:column>
					<p:column>
						<h:outputText value="#{searchBean.selectedLog.hostname}" />
					</p:column>
				</p:row>
				<p:row>
					<p:column>
						<h:outputText value="Facility:" />
					</p:column>
					<p:column>
						<h:outputText value="#{searchBean.selectedLog.facility}" />
					</p:column>
				</p:row>
			</p:panelGrid>
		</p:dialog>
	</ui:define>
</ui:composition>
